PHPでSQL Anywhereにデータを挿入する

 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
 
    #*********************************************************************     
    # Description:
    # Inserting data into a SQL Anywhere database can be accomplished by
    # performing asasql_query() call to execute an INSERT statement.
    # Thesasql_query() function prepares and executes the INSERT statement
    # identified by the connection that is passed in.
    #
    #*********************************************************************
 
    # Connect using the default user ID and password
    $conn =
sasql_connect ( "UID=DBA;PWD=sql" ) ;
    if ( ! $conn ) {
        echo "Could not connect! \n " ;
        echo
sasql_error ( ) ;
        exit ( ) ;
    }
    echo "Connected successfully! \n " ;
 
    # Execute an INSERT statement
    $stmt = 'INSERT INTO my_test_table VALUES
            ( \' John \' , \' Hello World \' )'
;
    $result =
sasql_query ( $conn , $stmt ) ;
 
    # Report any errors
    if ( ! $result ) {
        echo "sasql_query failed!" ;
    } else {
        echo "query completed successfully \n " ;
    }
    sasql_close ( $conn ) ;
 
?>

Copyright 2011 iAnywhere Solutions, Inc. All rights reserved. This sample code is provided AS IS, without warranty or liability of any kind.


BACK : 技術情報(サンプルコード&ユーティリティ)のトップページ
 
このウインドウを閉じる
 
Copyright 2011 iAnywhere Solutions K.K.